package osmparser;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.io.WKBWriter;
import java.util.Map;

/**
 * 
 * @author Xiaohui
 */
public class OSMNode extends AbstractNode {

	public String lat;
	public String lon;
	public static final String type = "osmNode";

	public OSMNode(String id, String visible, String timestamp, String version,
			String changeset, String user, String uid, String lat, String lon,
			Map<String, String> tags) {
		super(id, type, visible, timestamp, version, changeset, user, uid, tags);
		this.lat = lat;
		this.lon = lon;
		this.tags = tags;
	}

	public String getLocation() {
		Point p = new GeometryFactory().createPoint(new Coordinate(Double
				.valueOf(lon), Double.valueOf(lat)));

		return WKBWriter.bytesToHex(new WKBWriter().write(p));
	}

	public String toString() {
		return "<node id=" + id + " lat=" + lat + " lon=" + lon + ">";
	}

}